/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import controller.AdminKontrol;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import model.KategoriPenyakit;
import model.Obat;
import tabelmodel.ObatTableModel;

/**
 *
 * @author Dell
 */
public class frameDAFTAROBATDOKTER extends javax.swing.JFrame {

    /**
     * Creates new form frameDAFTAROBATDOKTER
     */
    public frameDAFTAROBATDOKTER() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktopPane1 = new javax.swing.JDesktopPane();
        detail = new javax.swing.JInternalFrame();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtkodeobat = new javax.swing.JTextField();
        txtnamaobat = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtkategori = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        komposisi = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        indikasi = new javax.swing.JTable();
        jScrollPane4 = new javax.swing.JScrollPane();
        kontraindikasi = new javax.swing.JTable();
        jScrollPane5 = new javax.swing.JScrollPane();
        perhatian = new javax.swing.JTable();
        jScrollPane6 = new javax.swing.JScrollPane();
        dosis = new javax.swing.JTable();
        jScrollPane7 = new javax.swing.JScrollPane();
        kemasan = new javax.swing.JTable();
        jScrollPane8 = new javax.swing.JScrollPane();
        efeksamping = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabelOBATDOKTER = new javax.swing.JTable();
        butonHomeDaftarObatDokter = new javax.swing.JButton();
        butonKembaliDaftarObatDokter = new javax.swing.JButton();
        btnDetailADMIN = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel2.setText("Kode Obat");

        jLabel3.setText("Nama Obat");

        txtnamaobat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtnamaobatActionPerformed(evt);
            }
        });

        jLabel4.setText("Kategori");

        txtkategori.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtkategoriActionPerformed(evt);
            }
        });

        jButton1.setText("Keluar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        komposisi.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "KOMPOSISI"
            }
        ));
        jScrollPane2.setViewportView(komposisi);

        indikasi.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "INDIKASI"
            }
        ));
        jScrollPane3.setViewportView(indikasi);

        kontraindikasi.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "KONTRA INDIKASI"
            }
        ));
        jScrollPane4.setViewportView(kontraindikasi);

        perhatian.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "PERHATIAN"
            }
        ));
        jScrollPane5.setViewportView(perhatian);

        dosis.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "DOSIS"
            }
        ));
        jScrollPane6.setViewportView(dosis);

        kemasan.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "KEMASAN"
            }
        ));
        jScrollPane7.setViewportView(kemasan);

        efeksamping.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "EFEK SAMPING"
            }
        ));
        jScrollPane8.setViewportView(efeksamping);

        javax.swing.GroupLayout detailLayout = new javax.swing.GroupLayout(detail.getContentPane());
        detail.getContentPane().setLayout(detailLayout);
        detailLayout.setHorizontalGroup(
            detailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(detailLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(detailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, detailLayout.createSequentialGroup()
                        .addGroup(detailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, detailLayout.createSequentialGroup()
                                .addGroup(detailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel2))
                                .addGap(83, 83, 83)
                                .addGroup(detailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtkategori)
                                    .addComponent(txtnamaobat)
                                    .addComponent(txtkodeobat, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE)))
                            .addGroup(detailLayout.createSequentialGroup()
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, detailLayout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addGap(26, 26, 26))))
        );
        detailLayout.setVerticalGroup(
            detailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(detailLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(detailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtkodeobat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(detailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtnamaobat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(detailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtkategori, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(detailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane7, 0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane8, 0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane5, 0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane4, 0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane3, 0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.TRAILING, 0, 0, Short.MAX_VALUE))
                .addGap(17, 17, 17)
                .addComponent(jButton1)
                .addGap(132, 132, 132))
        );

        detail.setBounds(0, 0, 930, 510);
        jDesktopPane1.add(detail, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("DAFTAR OBAT");

        tabelOBATDOKTER.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Kode Obat", "Nama Obat", "Kategori"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tabelOBATDOKTER);
        tabelOBATDOKTER.getColumnModel().getColumn(0).setResizable(false);
        tabelOBATDOKTER.getColumnModel().getColumn(1).setResizable(false);
        tabelOBATDOKTER.getColumnModel().getColumn(2).setResizable(false);

        butonHomeDaftarObatDokter.setText("Home");
        butonHomeDaftarObatDokter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butonHomeDaftarObatDokterActionPerformed(evt);
            }
        });

        butonKembaliDaftarObatDokter.setText("Kembali");
        butonKembaliDaftarObatDokter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butonKembaliDaftarObatDokterActionPerformed(evt);
            }
        });

        btnDetailADMIN.setText("Detail");
        btnDetailADMIN.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDetailADMINActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(200, 200, 200)
                        .addComponent(btnDetailADMIN)
                        .addGap(40, 40, 40)
                        .addComponent(butonHomeDaftarObatDokter)
                        .addGap(28, 28, 28)
                        .addComponent(butonKembaliDaftarObatDokter))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 980, Short.MAX_VALUE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 980, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jLabel1)
                .addGap(32, 32, 32)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 204, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(butonHomeDaftarObatDokter)
                    .addComponent(butonKembaliDaftarObatDokter)
                    .addComponent(btnDetailADMIN))
                .addGap(22, 22, 22))
        );

        jPanel1.setBounds(0, 0, 1000, 470);
        jDesktopPane1.add(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 998, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void butonHomeDaftarObatDokterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butonHomeDaftarObatDokterActionPerformed
frameHOMEPAGE fhp = new frameHOMEPAGE();
fhp.setVisible(true);
dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_butonHomeDaftarObatDokterActionPerformed

    private void butonKembaliDaftarObatDokterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butonKembaliDaftarObatDokterActionPerformed
dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_butonKembaliDaftarObatDokterActionPerformed

    private void btnDetailADMINActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDetailADMINActionPerformed
        //        // TODO add your handling code here:

//        tampilKomposisiDetail();
//        tampilindikasidetail();
//        tampilKontraIndikasiDetail();
//        tampilefekDetail();
//        tampilPerhatianDetail();
//        tampilDosisDetail();
//        tampilKemasanDetail();
        detail.setVisible(true);
}//GEN-LAST:event_btnDetailADMINActionPerformed

    private void txtnamaobatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtnamaobatActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtnamaobatActionPerformed

    private void txtkategoriActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtkategoriActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtkategoriActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        detail.setVisible(false);
        txtkategori.setText("");
        txtkodeobat.setText("");
        txtnamaobat.setText("");
}//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frameDAFTAROBATDOKTER.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frameDAFTAROBATDOKTER.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frameDAFTAROBATDOKTER.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frameDAFTAROBATDOKTER.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frameDAFTAROBATDOKTER().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnDetailADMIN;
    private javax.swing.JButton butonHomeDaftarObatDokter;
    private javax.swing.JButton butonKembaliDaftarObatDokter;
    private javax.swing.JInternalFrame detail;
    private javax.swing.JTable dosis;
    private javax.swing.JTable efeksamping;
    private javax.swing.JTable indikasi;
    private javax.swing.JButton jButton1;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JTable kemasan;
    private javax.swing.JTable komposisi;
    private javax.swing.JTable kontraindikasi;
    private javax.swing.JTable perhatian;
    private javax.swing.JTable tabelOBATDOKTER;
    private javax.swing.JTextField txtkategori;
    private javax.swing.JTextField txtkodeobat;
    private javax.swing.JTextField txtnamaobat;
    // End of variables declaration//GEN-END:variables

    private void tampilKategori() {
        try {
           // comboDataKategoriPenyakit.removeAllItems();
            List<KategoriPenyakit> daftarkategoris = AdminKontrol.getKoneksiKategori().lihatSeluruhKategori();
            for (int i = 0; i < daftarkategoris.size(); i++) {
                KategoriPenyakit kategori = daftarkategoris.get(i);
               // comboDataKategoriPenyakit.addItem(kategori.getKodeKategori() + " " + kategori.getNamaKategori());

            }
        } catch (SQLException ex) {
            Logger.getLogger(frameDAFTAROBATDOKTER.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void tampilObat() {
        try {
            List<Obat> daftarobat = AdminKontrol.getKoneksiKategori().lihatSeluruhObat();
            ObatTableModel model = new ObatTableModel(daftarobat);
            tabelOBATDOKTER.setModel(model);
        } catch (SQLException ex) {
            Logger.getLogger(frameDAFTAROBATDOKTER.class.getName()).log(Level.SEVERE, null, ex);
        }
    }



}
